package com.cust.cow.controller;

import com.cust.cow.common.CowMatingLog;
import com.cust.cow.common.Result;
import com.cust.cow.pojo.cowCattle;
import com.cust.cow.service.CowCattleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/cowCattle")
@CrossOrigin("*")
public class CowCattleController {
    @Autowired
    CowCattleService cowCattleService;

    @RequestMapping("findCowCattleAll")
    public List<cowCattle> findCowCattleAll()
    {
        return cowCattleService.findCowCattleAll();
    }

    @PostMapping("insertCowCattle")
    public Result insertCowCattle(@RequestBody cowCattle cowCattle)
    {
        return cowCattleService.insertCowCattle(cowCattle);
    }

    @RequestMapping("deleteCowCattle")
    public Result deleteCowCattle(@RequestParam("cattleId") Integer cattleId){
        return cowCattleService.deleteCowCattle(cattleId);
    }

    @RequestMapping("findCowCattleById")
    public CowMatingLog findCottleById(@RequestParam("cattleId") Integer cattleId){
        return cowCattleService.findCowCattleById(cattleId);
    }

    @RequestMapping("findCowCattleMatingLogAll")
    public List<CowMatingLog> findCowCattleMatingLogAll(){
        return cowCattleService.findCowCattleMatingLogAll();
    }


    @PostMapping("updateCowCattleProductionStatus")
    public Result updateCowCattleProductionStatus(@RequestBody cowCattle cowCattle){
        return cowCattleService.updateCowCattleProductionStatus(cowCattle);
    }
}
